package com.tledu.store.service.impl;

import com.tledu.common.utils.DateUtils;
import com.tledu.common.utils.SecurityUtils;
import com.tledu.store.domain.StoreHouse;
import com.tledu.store.mapper.StoreHouseMapper;
import com.tledu.store.service.IStoreHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 库房Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-08-29
 */
@Service
public class StoreHouseServiceImpl implements IStoreHouseService 
{
    @Autowired
    private StoreHouseMapper storeHouseMapper;

    /**
     * 查询库房
     * 
     * @param id 库房主键
     * @return 库房
     */
    @Override
    public StoreHouse selectStoreHouseById(Long id)
    {
        return storeHouseMapper.selectStoreHouseById(id);
    }

    @Override
    public List<StoreHouse> selectUnFullStoreHouseList(StoreHouse storeHouse) {
        return storeHouseMapper.selectUnFullStoreHouseList(storeHouse);
    }

    /**
     * 查询库房列表
     * 
     * @param storeHouse 库房
     * @return 库房
     */
    @Override
    public List<StoreHouse> selectStoreHouseList(StoreHouse storeHouse)
    {
        return storeHouseMapper.selectStoreHouseList(storeHouse);
    }

    /**
     * 新增库房
     * 
     * @param storeHouse 库房
     * @return 结果
     */
    @Override

    public int insertStoreHouse(StoreHouse storeHouse)
    {
        storeHouse.setCreateTime(DateUtils.getNowDate());
        storeHouse.setUpdateTime(DateUtils.getNowDate());
        storeHouse.setCreateUser(SecurityUtils.getUserId());
        storeHouse.setUpdateBy(SecurityUtils.getUsername());
        return storeHouseMapper.insertStoreHouse(storeHouse);
    }


    /**
     * 修改库房
     * 
     * @param storeHouse 库房
     * @return 结果
     */
    @Override

    public int updateStoreHouse(StoreHouse storeHouse)
    {
        return storeHouseMapper.updateStoreHouse(storeHouse);
    }

    /**
     * 批量删除库房
     * 
     * @param ids 需要删除的库房主键
     * @return 结果
     */
    @Override
    public int deleteStoreHouseByIds(Long[] ids)
    {
        return storeHouseMapper.deleteStoreHouseByIds(ids);
    }

    /**
     * 删除库房信息
     *
     * @param id 库房主键
     * @return 结果
     */
    @Override
    public int deleteStoreHouseById(Long id)
    {
        return storeHouseMapper.deleteStoreHouseById(id);
    }

    //逻辑批量删除库房
    public int logicdeleteStoreHouseByIds(Long[] ids) {
        return storeHouseMapper.logicdeleteStoreHouseByIds(ids);
    }

    //逻辑删除库房

//    public int logicdeleteStoreHouseByIds(Long id) {
//        return storeHouseMapper.logicdeleteStoreHouseById(id);
//    }

    //应该定义在参试设备中,来判断进行更新库房的状态是否已满,而不是在这里;
    private void isNeedUpdate(){
        storeHouseMapper.isNeedUpdate();
    }
}
